package spbgpu.ftf.pobiim.logic;

import java.util.SortedMap;
import java.util.TreeMap;

public class ConstantEq implements Equation {

	public SortedMap<Double, Double> calculateEquation() {
		SortedMap<Double, Double> result = new TreeMap<Double, Double>();

		Double startAngle = 45d;
		Double sinAngleOfIncidence = Math.sin(startAngle * Math.PI / 180);
		Double sinAngleOfRefraction;
		Double n = 0.709;
		Double x = 0d;
		for (Double y = 0d; y < 10; y=y+0.1) {

			sinAngleOfRefraction = sinAngleOfIncidence / n;
			n = 1d;

			Double cosAngleOfRefraction = Math.sqrt(1 - sinAngleOfRefraction
					* sinAngleOfRefraction);

			x = Math.sqrt(y * y / (cosAngleOfRefraction * cosAngleOfRefraction)
					- y * y);
			System.out.println(x + " " + y);
			result.put(x, y);
			sinAngleOfIncidence = sinAngleOfRefraction;

		}

		return result;
	}

	@Override
	public String getLabel() {
		return "n = 0.709";
	}

	@Override
	public String getName() {
		return "constant";
	}

}
